Expand description

Music theory library with midi, notes, chords, scales, and more

Examples

Create a C Major (1st inversion) chord and iterate over its notes.

use music_note::{midi, Chord, Pitch};

// C/E
let chord = Chord::from_midi(
    midi!(C, 4),
    [midi!(E, 3), midi!(G, 3), midi!(C, 4)]
);

assert_eq!(chord.to_string(), "C/E");

let pitches = [Pitch::E, Pitch::G, Pitch::C];
assert!(chord.into_iter().eq(pitches));

Create a C Major scale and iterate over its notes.

use music_note::{midi, Note, Scale};

// C major
let scale = Scale::major(midi!(C, 4));

assert!(scale.eq([
    midi!(C, 4),
    midi!(D, 4),
    midi!(E, 4),
    midi!(F, 4),
    midi!(G, 4),
    midi!(A, 4),
    midi!(B, 4),
]));

Re-exports

pub use chord::Chord;
pub use staff::Staff;
pub use note::Note;
pub use scale::Scale;

Modules

Macros

Structs

Music interval in semitones.

A key signature represented as the total number of sharps or flats.

Enums

A natural pitch

Pitch class that can be found on the chromatic scale.